using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MapMaker
{
    public partial class frmMain : Form
    {
        private frmMap mapViewer = null;
        private frmDirections directionsForm = null;
        private frmExportToPOI exportPOIForm = null;
        private frmProgress progressForm = null;

        public frmMain()
        {
            InitializeComponent();
            mapViewer = new frmMap();
            mapViewer.MdiParent = this;
		}

		public frmMap MapViewerForm
		{
			get
			{
				if (mapViewer == null || mapViewer.IsDisposed)
				{
					mapViewer = new frmMap();
					mapViewer.MdiParent = this;
				}
				
				return mapViewer;
            }
        }

        public frmDirections DirectionsForm
        {
            get
            {
                if (directionsForm == null || directionsForm.IsDisposed)
                {
                    directionsForm = new frmDirections();
                    directionsForm.MdiParent = this;
                }

                return directionsForm;
            }
        }

		public frmProgress ProgressForm
		{
			get
			{				
				return progressForm;
			}
            set
            {
                progressForm = value;
            }
		}

        public ToolStripMenuItem ExportToPOIMenu
        {
            get
            {
                return mnuRoute_ExportPOI;
            }
        }

        public frmExportToPOI ExportPOIForm
        {
            get
            {
                if (exportPOIForm == null || exportPOIForm.IsDisposed)
                {
                    exportPOIForm = new frmExportToPOI();
                    exportPOIForm.MdiParent = this;
                }

                return exportPOIForm;
            }
        }



        private void mnuFile_Exit_Click(object sender, EventArgs e)
        {
            // confirm exit with the user
            if (MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            // show the map by default
            MapViewerForm.Show();
        }

        private void mnuRoute_Directions_Click(object sender, EventArgs e)
        {
            // show the map viewer
            MapViewerForm.Show();

            // show the directions form
            DirectionsForm.Show();
            DirectionsForm.BringToFront();
        }

        private void mnuRoute_ExportPOI_Click(object sender, EventArgs e)
        {
            // show the export to POI form
            ExportPOIForm.Show();
        }
    }
}